import javax.microedition.lcdui.Graphics;

/**
 * 
 */

/**
 * @author Family
 *
 */
public class Menu extends  java.lang.Object {
	public static int currentMenuIndex = -1;
	public static int currentMenuCount = 0;
	public static String m_itemsList[];
 static public void drawMenuBg(Graphics g)
 {
	g.setClip(0, 0,GameEngine.getScreenWidth(), GameEngine.getScreenHeight());
	g.setColor(255,255,255);//whited
	g.fillRect(0, 0,GameEngine.getScreenWidth(), GameEngine.getScreenHeight());
	GameManage.s_imageManage.drawMenuBg(g);
 }
 
 static public void drawMenuBg(Graphics g,int posX,int posY,int width,int height)
 {
	g.setClip(posX, posY, width,height);
	g.setColor(255,255,255);//white
	g.fillRect(posX, posY, width,height);
	g.setClip(0, 0,GameEngine.getScreenWidth(), GameEngine.getScreenHeight());
 }
 
 static public void drawItems(Graphics g,String itemList[],int selectItem)
 {
	 int leng =itemList.length;
	 int screenHalfWidth = GameEngine.getScreenWidth() >>1;
	 int lineSpace = 25;//20;
	 g.setColor(0, 0, 0);
	 for(int i =0; i < leng; i++)
		 g.drawString(itemList[i], screenHalfWidth, 15 + i* lineSpace , Graphics.HCENTER | Graphics.TOP);
	 
	 g.setColor(0, 0, 255);
	 g.drawString(itemList[selectItem], screenHalfWidth, 15 + selectItem * lineSpace , Graphics.HCENTER | Graphics.TOP);
	 
 }
 
 static public void drawItems(Graphics g,int posY,String itemList[], int selectItem,int spaceLine)
 {
	 int leng =itemList.length;
	 int screenHalfWidth = GameEngine.getScreenWidth() >>1;
	 g.setColor(0, 0, 0);
	 for(int i =0; i < leng; i++)
		 g.drawString(itemList[i], screenHalfWidth, posY + i* spaceLine , Graphics.HCENTER | Graphics.TOP);
 }
 
 static public void drawItems(Graphics g,int posY,String itemList[],int selectItem)
 {
	 int leng =itemList.length;
	 int screenHalfWidth = GameEngine.getScreenWidth() >>1;
	 int lineSpace = 25;/// 15;
	 g.setColor(0, 0, 0);
	 for(int i =0; i < leng; i++)
		 g.drawString(itemList[i], screenHalfWidth, posY + i* lineSpace , Graphics.HCENTER | Graphics.TOP);
	 
	 g.setColor(0, 0, 255);
	 g.drawString(itemList[selectItem], screenHalfWidth, posY + selectItem * lineSpace , Graphics.HCENTER | Graphics.TOP);
	 
 }
	
 static public int getCurrentMenuIndex()
 {
	 return currentMenuIndex;
 }
 
 static public int getCurrentMenuCount()
 {
	 return currentMenuCount;
 }
 
 static public void setCurrentMenuIndex(int id)
 {
	 currentMenuIndex = id;
 }
 
 
 static public void setMenuItems(String itemList[])
 {
	 setMenuItems(-1,itemList);
 }
 static public void setMenuItems(int menuId,String itemList[])
 {
	 m_itemsList = itemList;
	 if(itemList==null)
	 currentMenuCount =0;
	 else
	 currentMenuCount = itemList.length;
	 currentMenuIndex = 0;
 }
 
 
 static public void setMenuItemsWithTitle(String itemList[])
 {
	 m_itemsList = itemList;
	 currentMenuCount = itemList.length;
	 currentMenuIndex = 0;
 }
 
 
 static public void drawTitles(Graphics g,String titleString)
 {
	 int screenHalfWidth = GameEngine.getScreenWidth() >>1;
	 int lineSpace = 15;
	 g.setColor(0, 0, 0);
	g.drawString(titleString, screenHalfWidth, 15  , Graphics.HCENTER | Graphics.TOP);
	 
//	 g.setColor(0, 0, 255);
//	 g.drawString(itemList[selectItem], screenHalfWidth, 15 + selectItem * lineSpace , Graphics.HCENTER | Graphics.TOP);
	 
 }
 
 static public void drawItemsTitles(Graphics g,String titleItemsList[],int selectItem,int posY)
 {
	 int screenHalfWidth = GameEngine.getScreenWidth() >>1;
	 int lineSpace = 25;///15;
	 //draw title
	 g.setColor(0, 0, 0);
	g.drawString(titleItemsList[0], screenHalfWidth,30 + lineSpace, Graphics.HCENTER | Graphics.TOP);
	 
	//draw items
    g.drawString(titleItemsList[ 1 + selectItem], screenHalfWidth, 30 + lineSpace*2 , Graphics.HCENTER | Graphics.TOP);

 }
 
 
 static public void drawItemsTitles(Graphics g,String titleItemsList[],int selectItem,int posY,boolean bIsChoosed)
 {
	 //posY = 30
	 int screenHalfWidth = GameEngine.getScreenWidth() >>1;
	 int lineSpace = 15;
	 //draw title
	 g.setColor(0, 0, 0);
	g.drawString(titleItemsList[0], screenHalfWidth,posY + lineSpace, Graphics.HCENTER | Graphics.TOP);
	 
	//draw items
	if(bIsChoosed)
	g.setColor(0, 0,255);
    g.drawString(titleItemsList[1 + selectItem], screenHalfWidth, posY + lineSpace*2 , Graphics.HCENTER | Graphics.TOP);

 }
 
}
